package com.example.devcaptcha.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description TODO
 * @Date 2023/1/29 14:31
 * @created by Wanghuafu
 * @Version 1.0.0
 */
@Slf4j
@Component
public class ContextPathHandler implements HandlerInterceptor {


    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        if (null!=modelAndView){
            log.info("path:{}",request.getContextPath());
            modelAndView.addObject("contextPath",request.getContextPath());
        }
//        HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
    }
}
